﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using TomShane.Neoforce.Controls;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.GamerServices;

namespace Orion.Lib
{
    public class MainMenuScreen : GameScreenBase
    {
        public MainMenuScreen()
            : base()
        { }

        public override void Initialize()
        {
            base.Initialize();

        }

        public override void LoadContent()
        {
            if (!isLoaded)
            {
                base.LoadContent();

                MyGame.Instance.IsMouseVisible = true;


                CreateTestButton();
            }
        }

        Window window;
        private void CreateTestButton()
        {
            // Create and setup Window control.
            window = new Window(MyGame.UIManager);
            window.Init();
            window.Text = "Orion Shooter v0.3";
            window.Width = 200;
            window.Height = 300;
            window.Center();
            window.Resizable = false;
            window.CloseButtonVisible = false;
            window.Visible = true;
            window.Movable = false;

            // Create Button control and set the previous window as its parent.
            var button = new Button(MyGame.UIManager);
            button.Init();
            button.Text = "Campaign";
            button.Width = 150;
            button.Height = 24;
            button.Click += button_Click;
            button.Left = (window.ClientWidth / 2 - button.Width / 2);
            button.Top = (window.ClientHeight / 2 - button.Height / 2) - 36;
            button.Anchor = Anchors.Horizontal | Anchors.Vertical;
            button.Parent = window;

            var button2 = new Button(MyGame.UIManager);
            button2.Init();
            button2.Text = "Network Coop";
            button2.Width = 150;
            button2.Height = 24;
            button2.Enabled = false;
            button2.Left = (window.ClientWidth / 2 - button2.Width / 2);
            button2.Top = (window.ClientHeight / 2 - button2.Height / 2);
            button2.Anchor = Anchors.Horizontal | Anchors.Vertical;
            button2.Parent = window;

            var button4 = new Button(MyGame.UIManager);
            button4.Init();
            button4.Text = "Play LIVE";
            button4.Width = 150;
            button4.Height = 24;
            button4.Enabled = false;
            button4.Left = (window.ClientWidth / 2 - button4.Width / 2);
            button4.Top = (window.ClientHeight / 2 - button4.Height / 2) + 36;
            button4.Anchor = Anchors.Horizontal | Anchors.Vertical;
            button4.Parent = window;
            button4.Click += new TomShane.Neoforce.Controls.EventHandler(button4_Click);

            var button3 = new Button(MyGame.UIManager);
            button3.Init();
            button3.Text = "Exit";
            button3.Width = 150;
            button3.Height = 24;
            button3.Left = (window.ClientWidth / 2 - button3.Width / 2);
            button3.Top = (window.ClientHeight / 2 - button3.Height / 2) + 72; 
            button3.Anchor = Anchors.Horizontal | Anchors.Vertical;
            button3.Parent = window;
            button3.Click += new TomShane.Neoforce.Controls.EventHandler(button3_Click);
            // Add the window control to the manager processing queue.
            MyGame.UIManager.Add(window);
        }

        void button4_Click(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            Guide.ShowSignIn(2, false);
            //NetworkSession networkSession = NetworkSession.Create(NetworkSessionType.Local, 2, 2);
        }

        void button3_Click(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
           
            MyGame.Instance.Exit();
        }

        void button_Click(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            window.Close();
            MyGame.Instance.SwitchScreen(new LevelListScreen(), true);
        }

        //void testb_OnClick(object sender, EventArgs e)
        //{
        //    MyGame.Instance.SwitchScreen(new LevelListScreen(), true);
        //}

        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            
            base.Update(gameTime);
        }

        public override void Draw(Microsoft.Xna.Framework.GameTime gameTime)
        {
         
            GraphicsDevice.Clear(Color.DarkGray);
          
            base.Draw(gameTime);

        }
    }
}
